'use strict';

const BaseController = require('../sys/base');

const Controller = require('egg').Controller;

class RoleController extends BaseController {

  // 添加角色
  async add() {
    const { ctx } = this;
    const postData = ctx.request.body;
    const result = await ctx.service.organization.role.add(postData);
    this.success(result);
  }

  // 获取角色
  async list() {
    const { ctx } = this;
    const result = await ctx.service.organization.role.list(ctx.request.query);
    this.success(result);
  }

  // 更新角色
  async update() {
    const { ctx } = this;
    const postData = ctx.request.body;
    const result = await ctx.service.organization.role.update(postData);
    this.success(result);
  }

  // 删除角色
  async delete() {
    const { ctx } = this;
    const result = await ctx.service.organization.role.delete(ctx.query.id);
    this.success(result);
  }

}

module.exports = RoleController;
